<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>

<%@page import="login.User"
        import="java.util.HashMap"
        import="java.lang.String"
        import="application.Seed"%>
<%@ include file="WEB-INF/jspf/header.jspf" %>
<%
String user = ((User)session.getAttribute("currentSessionUser")).getUsername();
String seedAdded = request.getParameter("seedAdded");
%>
    <div class="userSeedsDiv">
        <h3>
        <%= user %>'s Seeds<%if(seedAdded!=null){%><%=", "+request.getParameter("seedAdded")+" seed added"%><% }%>
        </h3>
        <sql:query var="userSeeds" dataSource="jdbc/CS2340SeedSwap">
            SELECT name,scientificName,hardiness,quantity,price FROM seeds 
            WHERE sellerUsername= '<%=user.replaceAll("'","''")%>'
            ORDER BY ID DESC
        </sql:query>
        
        <table border="1">
            <!-- column headers -->
            <tr>
                <th>Name</th>
                <th>Scientific Name</th>
                <th>Hardiness</th>
                <th>Quantity (kg.)</th>
                <th>Price</th>
            </tr>
            <!-- column data -->
            <c:forEach var="row" items="${userSeeds.rowsByIndex}">
                <tr>
                <c:forEach var="column" items="${row}">
                    <td><c:out value="${column}"/></td>
                </c:forEach>
                </tr>
            </c:forEach>
        </table>
    </div>
<%@ include file="WEB-INF/jspf/footer.jspf" %>